package com.hp.ams.ongoing.netatendimento.view.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import com.hp.ams.ongoing.netatendimento.model.entity.Categorizacao;

@FacesConverter(value="categorizacaoConverter")
public class CategorizacaoConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
		Categorizacao vo = new Categorizacao();
		if (!(arg2.equals(""))){
			String[] arr = arg2.split("\\-");
		vo = new Categorizacao(new Integer(arr[0]), arr[1]);
		}
		return vo;
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
		Categorizacao vo = new Categorizacao();
		if (!(arg2.equals("")))
			vo = (Categorizacao) arg2;
		return vo.toString();
	}

}
